package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import java.security.KeyStore;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;


public class LoadingActivity extends Activity
{
    Timer timer = new Timer();//构造定时器

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);


        //隐藏标题栏以及状态栏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        //标题是属于View的，所以窗口所有的修饰部分被隐藏后标题依然有效,需要去掉标题
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.activity_loading);


        TimerTask task = new TimerTask()
        {
            @Override
            public void run()
            {
                Intent intent =new Intent(LoadingActivity.this,MainActivity.class);
                startActivity(intent);
                finish();
            }
        };
        timer.schedule(task, 1000);
    }

    public void onStop()
    {
        super.onStop();
        timer.cancel();     //关闭页面后自动注销计时器
    }
}